package com.xd.study.utility;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by DGF on 2015/4/28.
 */
public class MyFragmentStatePagerAdapter extends FragmentStatePagerAdapter {

    List<Fragment> fragmentList = null;
    List<String> titleList = null;

    public MyFragmentStatePagerAdapter(FragmentManager fm, List<Fragment> fragments, List<String> titles) {
        super(fm);
        this.fragmentList = fragments;
        this.titleList = titles;
    }

    @Override
    public Fragment getItem(int i) {
        return this.fragmentList.get(i);
    }

    @Override
    public int getCount() {
        return this.fragmentList.size();
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        super.destroyItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return this.titleList.get(position);
    }
}
